/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cinema.view;

import cinema.controler.CinemaControler;
import cinema.model.Arquivo;
import cinema.model.Cinema;
import java.awt.Color;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/**
 *
 * @author AlisonSM
 */
public class CinemaView extends javax.swing.JFrame {
    private CinemaControler controler;
    private Cinema model;
    /**
     * Creates new form NewJFrame
     */
    public CinemaView() {
        initComponents();
        model = new Cinema();
        controler = new CinemaControler(this, model, jTable1, jLabel7);
        controler.VerificaArquivoVazio();
        botãoRegistrarVenda.setEnabled(false);
        botãoSalvar.setEnabled(false);
        ImageIcon img = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/michael.gif");
        ImageIcon imgSala = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/sala.jpg");
        jLabel12.setIcon(img);
        jLabel11.setIcon(imgSala);
        controler.runThread();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        botãoRegistrarVenda = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        campoIngressosVendidos = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        campoIngressosDisponiveis = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        botãoSalvar = new javax.swing.JButton();
        botãoGerarCSV = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        campoNomedoFilme = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        campoData = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        campoHorário = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        botãoCadastrarSessão = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        CampoNúmeroDaSala = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        botãoCadastrarSala = new javax.swing.JToggleButton();
        CampoLotaçãoMáxima = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        botãoRegistrarVenda.setText("Registrar Venda");
        botãoRegistrarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botãoRegistrarVendaActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel6.setText("Sessões:");

        campoIngressosVendidos.setEditable(false);
        campoIngressosVendidos.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel5.setText("Ingressos Vendidos:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel8.setText("Ingressos Dísponiveis:");

        campoIngressosDisponiveis.setEditable(false);
        campoIngressosDisponiveis.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Filme", "Data", "Horário", "Sala"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTable1MousePressed(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jLabel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        botãoSalvar.setText("Salvar Histórico");
        botãoSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botãoSalvarActionPerformed(evt);
            }
        });

        botãoGerarCSV.setText("Gerar \".csv\"");
        botãoGerarCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botãoGerarCSVActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(42, 42, 42)
                                .addComponent(botãoRegistrarVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(botãoSalvar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(botãoGerarCSV, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel5)
                                            .addComponent(jLabel8))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(campoIngressosDisponiveis)
                                            .addComponent(campoIngressosVendidos))))
                                .addGap(16, 16, 16))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 584, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(campoIngressosVendidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(campoIngressosDisponiveis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(botãoRegistrarVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(34, 34, 34)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(botãoGerarCSV, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                            .addComponent(botãoSalvar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Venda de Ingressos", jPanel1);

        campoNomedoFilme.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel1.setText("Nome do Filme:");

        try {
            campoData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        campoData.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        campoData.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        campoData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                campoDataMousePressed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setText("Data:");

        try {
            campoHorário.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##h(s):##min.")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        campoHorário.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        campoHorário.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                campoHorárioMousePressed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel3.setText("Horário:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel4.setText("Número da Sala:");

        botãoCadastrarSessão.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        botãoCadastrarSessão.setText("Cadastrar Sessão");
        botãoCadastrarSessão.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botãoCadastrarSessãoActionPerformed(evt);
            }
        });

        jLabel12.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botãoCadastrarSessão, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(campoNomedoFilme, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(campoData, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(campoHorário, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(57, 57, 57)
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(jLabel1)
                        .addGap(17, 17, 17)
                        .addComponent(jLabel2)
                        .addGap(17, 17, 17)
                        .addComponent(jLabel3)
                        .addGap(23, 23, 23)
                        .addComponent(jLabel4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(campoNomedoFilme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(campoData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(campoHorário, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addComponent(botãoCadastrarSessão, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTabbedPane1.addTab("Cadastro de Sessões", jPanel2);

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel9.setText("Número da Sala:");

        CampoNúmeroDaSala.setEditable(false);
        CampoNúmeroDaSala.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel10.setText("Lotação Máxima:");

        botãoCadastrarSala.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        botãoCadastrarSala.setText("Cadastrar Sala");
        botãoCadastrarSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botãoCadastrarSalaActionPerformed(evt);
            }
        });

        CampoLotaçãoMáxima.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                CampoLotaçãoMáximaMousePressed(evt);
            }
        });

        jLabel11.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(CampoNúmeroDaSala, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(CampoLotaçãoMáxima, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(botãoCadastrarSala, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(444, 448, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(CampoNúmeroDaSala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(CampoLotaçãoMáxima, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addComponent(botãoCadastrarSala, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36))
        );

        jTabbedPane1.addTab("Cadastro de Salas", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botãoRegistrarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botãoRegistrarVendaActionPerformed
        // TODO add your handling code here:
        int linha = jTable1.getSelectedRow();
        controler.vendeIngresso(linha);
        ImageIcon icone = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/popcorn.png");
        JOptionPane.showMessageDialog(this, "Venda Efetuada!", "Registro de Venda", 0, icone);
        botãoSalvar.setEnabled(true);
    }//GEN-LAST:event_botãoRegistrarVendaActionPerformed

    private void botãoCadastrarSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botãoCadastrarSalaActionPerformed
        // TODO add your handling code here:
        controler.cadastrarSala();
        botãoCadastrarSala.setSelected(false);        
    }//GEN-LAST:event_botãoCadastrarSalaActionPerformed

    private void botãoCadastrarSessãoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botãoCadastrarSessãoActionPerformed
        // TODO add your handling code here:
        controler.cadastrarSessão();
    }//GEN-LAST:event_botãoCadastrarSessãoActionPerformed

    private void campoDataMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_campoDataMousePressed
        // TODO add your handling code here:
        campoData.setScrollOffset(1);
    }//GEN-LAST:event_campoDataMousePressed

    private void campoHorárioMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_campoHorárioMousePressed
        // TODO add your handling code here:
        campoHorário.setScrollOffset(1);
    }//GEN-LAST:event_campoHorárioMousePressed

    private void jTable1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MousePressed
        // TODO add your handling code here:
        int n = jTable1.getSelectedRow();
        controler.atualizaingressos(n);
    }//GEN-LAST:event_jTable1MousePressed

    private void botãoSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botãoSalvarActionPerformed
        // TODO add your handling code here:
        controler.SalvaremArquivo();
        ImageIcon iconeSalvar = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/filme.png");
        JOptionPane.showMessageDialog(this, "Histórico foi salvo com sucesso!", "Salvar em Histórico", 0, iconeSalvar);
    }//GEN-LAST:event_botãoSalvarActionPerformed

    private void CampoLotaçãoMáximaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CampoLotaçãoMáximaMousePressed
        // TODO add your handling code here:
        CampoLotaçãoMáxima.selectAll();
    }//GEN-LAST:event_CampoLotaçãoMáximaMousePressed

    private void botãoGerarCSVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botãoGerarCSVActionPerformed
        // TODO add your handling code here:
        controler.gerarArquivoCSV();
                ImageIcon iconeCSV = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/csv.png");
        JOptionPane.showMessageDialog(this, "Arquivo foi gerado com Sucesso!", "Gerando Arquivo '.csv'", 0, iconeCSV);
    }//GEN-LAST:event_botãoGerarCSVActionPerformed
    
    public String getValoresSala(){
        String lotaçãoMáxima = CampoLotaçãoMáxima.getText();
        return lotaçãoMáxima;
    }
    
    public void setValoresSala(String valor, String numsala){
        CampoLotaçãoMáxima.setText(valor);
        CampoNúmeroDaSala.setText(numsala);
    }
    
    public ArrayList<String> getValoresSessão(){
        ArrayList<String> valores = new ArrayList<String>();
                valores.add(campoNomedoFilme.getText());
                valores.add(campoData.getText());
                valores.add(campoHorário.getText());
                valores.add(Integer.toString (jComboBox1.getSelectedIndex()));
                return valores;
    }
    
    public void setValoresSessão(int tamanho){
        if (tamanho > 0) {
            jComboBox1.addItem(tamanho);
        }
        else{
        campoNomedoFilme.setText(null);
        campoData.setText("00/00/0000");
        campoHorário.setText("00h(s):00min.");
        }
    }
    
    public void setValoresIngresso (String vendidos, String disponiveis){
        campoIngressosVendidos.setText(vendidos);
        campoIngressosDisponiveis.setText(disponiveis);        
    }
    
    public void SetEneabledBotõesSessão(boolean a){
        botãoCadastrarSessão.setEnabled(a);
        jComboBox1.setEnabled(a);
    }
    
    public void SetEneabledBotõesVenda(boolean a){
        botãoRegistrarVenda.setEnabled(a);
        campoIngressosDisponiveis.setBackground(Color.white);
        campoIngressosDisponiveis.setForeground(Color.black);
    }
    
    public void setAvisoEsgotado (){
        campoIngressosDisponiveis.setText("Esgotado!");
        campoIngressosDisponiveis.setBackground(Color.red);
        campoIngressosDisponiveis.setForeground(Color.white);
    }
    
    public void setEneabledBotãoSalvar(boolean a){
        botãoSalvar.setEnabled(a);
    }
    
    public void setEneabledBotãoGerarCSV(boolean a){    
        botãoGerarCSV.setEnabled(a);
    }
    
    public void AvisodeErroSala(){
        ImageIcon iconeErro = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/erro.png");
        JOptionPane.showMessageDialog(this, "Você deve informar um valor para lotação máxima!", "Aviso", 0, iconeErro);
    }
    
    public void AvisoErroSessão(){
        ImageIcon iconeErro = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/erro.png");
        JOptionPane.showMessageDialog(this, "Você deve informar o nome do filme!", "Aviso", 0, iconeErro);
    }
    
    public void AvisoSessãoCadastrada(){
        ImageIcon iconeSessão = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/clap.png");
        JOptionPane.showMessageDialog(this, "Sessão foi cadastrada com Sucesso!", "Cadastro de Sessão", 0, iconeSessão);
    }
    
    public void AvisoSalaCadastrada(){
        ImageIcon iconeSala = new ImageIcon("C:/Users/AlisonSM/Documents/NetBeansProjects/Cinema/Imagens/cinema.png");
        JOptionPane.showMessageDialog(this, "Sala foi cadastrada com Sucesso!", "Cadastro de Sala", 0, iconeSala);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField CampoLotaçãoMáxima;
    private javax.swing.JTextField CampoNúmeroDaSala;
    private javax.swing.JToggleButton botãoCadastrarSala;
    private javax.swing.JButton botãoCadastrarSessão;
    private javax.swing.JButton botãoGerarCSV;
    private javax.swing.JButton botãoRegistrarVenda;
    private javax.swing.JButton botãoSalvar;
    private javax.swing.JFormattedTextField campoData;
    private javax.swing.JFormattedTextField campoHorário;
    private javax.swing.JTextField campoIngressosDisponiveis;
    private javax.swing.JTextField campoIngressosVendidos;
    private javax.swing.JTextField campoNomedoFilme;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
